package com.ruoyi.project.cms.content.service;


import com.ruoyi.common.utils.security.ShiroUtils;
import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.project.cms.content.domain.Content;
import com.ruoyi.project.cms.content.mapper.ContentMapper;
import com.ruoyi.project.system.notice.domain.Notice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ContentServiceImpl implements IContentService {
    //声明mapper层属性
    @Autowired
    private ContentMapper contentMapper;
    @Override
    public List<Notice> selectContentList(Content content) {
        List<Notice> contents= contentMapper.selectContentList(content);

        return contents;
    }

    @Override
    public int insertContent(Content content) {
        content.setCreateBy(ShiroUtils.getLoginName());
        return contentMapper.insertContent(content);
    }

    @Override
    public int deleteContentByIds(String ids) {
        Long[] contentIds = Convert.toLongArray(ids);

      int i=  contentMapper.deleteContentByIds(contentIds);
        return i;
    }

    @Override
    public int updateContent(Content content) {
        content.setCreateBy(ShiroUtils.getLoginName());
        return contentMapper.updateContent(content);
    }

    @Override
    public Content selectContentById(Long contentId) {
        return contentMapper.selectContentById(contentId);
    }
}
